package com.always.electrical.energy.web.controller;

import com.always.electrical.energy.web.req.VerifyPwdReq;
import com.always.electrical.energy.web.res.VerifyPwdRes;
import com.always.electrical.energy.web.res.WebBaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 密码验证
 */
@RestController
@RequestMapping("/verify")
public class VerifyController {

    @Autowired
    private String pwd;

    /**
     * 启动密码验证
     */
    @PostMapping("/pwd")
    public WebBaseResponse pwd(@RequestBody VerifyPwdReq req) {
        return WebBaseResponse.success(new VerifyPwdRes().setState(Objects.equals(req.getPwd(), pwd) ? 0 : 1));
    }
}
